﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginListHistory.aspx.cs" Inherits="CRMWeb.Pages.Contact.LoginListHistory" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <table id="dgLoginHistory" style="width: auto" class="esyui-datagrid"
        rownumbers="true" fitcolumns="true" singleselect="true" autorowheight="true" width="70%">
        <thead>
            <tr>
                <th field="LoginDate" data-options="formatter:formatHistoryDate"  width="100px">LoginDate</th>
                <th field="LoginTime" data-options="formatter:formatHistoryTime" width="100px">LoginTime</th>
                <th field="Display_Name" width="100px">Display_Name</th>
                <th field="Email_Address" width="150px">Email_Address</th>
                <th field="LoginIP" width="100px">LoginIP</th>
                <th field="LoginBrowser" width="100px">LoginBrowser</th>
                 <th field="ComesFrom" width="100px">System</th>
            </tr>
        </thead>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#dgLoginHistory').datagrid({
                url: '/WebServices/History.ashx?method=GetLoginHistory&ContactID=' + getQuerystring('contact_id', ''),
                onDblClickRow: function (index, rowdata)
                {
                    //var hostUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
                   // var myWindow = window.open(hostUrl + '/Pages/Application/VedaResponseData/' + rowdata.XMLFile, '_blank');
                   // myWindow.focus();
                }
            });
        });


        function formatHistoryDate(value, row) {
            if (value == null)
                return '';
            var date = new Date(value);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var month = '';
            switch (m) {
                case 1:
                    month = 'Jan';
                    break;
                case 2:
                    month = 'Feb';
                    break;
                case 3:
                    month = 'Mar';
                    break;
                case 4:
                    month = 'Apr';
                    break;
                case 5:
                    month = 'May';
                    break;
                case 6:
                    month = 'Jun';
                case 7:
                    month = 'Jul';
                    break;
                case 8:
                    month = 'Aug';
                    break;
                case 9:
                    month = 'Sep';
                    break;
                case 10:
                    month = 'Oct';
                    break;
                case 11:
                    month = 'Nov';
                    break;
                case 12:
                    month = 'Dec';
                    break;
            }
            var d = date.getDate();
            return (d < 10 ? ('0' + d) : d) + ' ' + month + ' ' + y;
        }
        function DefaultformatHistoryDate(value) {
            dArr = value.split('/');
            return dArr[1] + '/' + dArr[0] + '/' + dArr[2];
        }
        function formatHistoryTime(value, row) {
            if (value == null)
                return '';

            var hourEnd = value.indexOf(':');
            var H = +value.substr(0, hourEnd);
            var minutes = value.substring(3, 5);
            var ampm = '';
            if (H == 00) {
                value = '00:' + minutes + 'AM';
            }
            else if (H == 12) {
                value = '12:' + minutes + 'PM';
            }
            else {
                var h = H % 12 || 12;
                ampm = H < 12 ? 'AM' : 'PM';
                value = h + value.substr(hourEnd, 3) + ampm;
            }
            return value;
        }
        function setHistoryTimeTo24(timeStr)
        {
            var meridian = timeStr.substr(timeStr.length - 2).toLowerCase();;
            var hours = timeStr.substr(0, timeStr.indexOf(':'));
            var minutes = timeStr.substring(3, 5);
            if (meridian == 'pm') {
                if (hours != 12)
                    hours = hours * 1 + 12;
            }
            else {
                if (hours == 12)
                    hours = 00;
            }
            return hours + ':' + minutes;
        }
    </script>
</body>
</html>
